package com.hust360.percent.pojo;

import java.util.Comparator;

/**
 * 改类中定义了各种排序接口的实现
 * 
 * @author yangyang
 * 
 */
public class SortInterfaceImpls {

	/*
	 * DiscountInfo对象的排序接口的实现类
	 */
	/*----------------------------------------------------------------------------------------*/

	/**
	 * 根据折扣排序的接口的实现类
	 * 
	 * @author yangyang
	 * 
	 */
	public static class SortByDiscountImpl implements Comparator<Discount> {

		public SortByDiscountImpl() {
		}

		@Override
		public int compare(Discount lhs, Discount rhs) {
			int cmp = lhs.discount.intValue()
					- rhs.discount.intValue();
			int cmp2 = lhs.disctype.intValue()
					- rhs.disctype.intValue();
			return cmp != 0 ? cmp : cmp2;
		}
	}

//	/**
//	 * 根据人气排序的接口实现类
//	 */
//	public static class SortByLikeImpl implements Comparator<DiscountInfo> {
//		@Override
//		public int compare(DiscountInfo lhs, DiscountInfo rhs) {
//			return (int) (lhs.getLiked().longValue() - rhs.getLiked()
//					.longValue()) * (-1);
//		}
//	}

	/**
	 * 根据最新活动排序
	 */
	public static class LatestImpl implements Comparator<Discount> {
		@Override
		public int compare(Discount lhs, Discount rhs) {
			return -1 * lhs.moddate.compareTo(rhs.moddate);
		}
	}

	/**
	 * 根据距离排序
	 */
	public static class DistanceImpl implements Comparator<Discount> {
		@Override
		public int compare(Discount lhs, Discount rhs) {
			return 0;
//			return (int) -(rhs.d - lhs.getDistance());
		}
	}

}
